//
//  CameraManger.h
//  AVFoundationCamera
//
//  Created by 李挺哲 on 16/1/14.
//  Copyright © 2016年 cmjstudio. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import <AssetsLibrary/AssetsLibrary.h>

typedef NS_ENUM(BOOL, CameraType) {
    FrontFacingCamera,
    RearFacingCamera,
};


@protocol CameraMangerDelegate <NSObject>

@optional
- (void)didCaptureImage:(NSData *)imageData path:(NSString *)imagePath;
- (void)didCaptureVideo:(NSData *)videoData path:(NSString *)videoPath;


@end
@interface CameraManger : NSObject<AVCaptureFileOutputRecordingDelegate>

@property (nonatomic, weak) AVCaptureDevice *activeCamera;
@property (strong,nonatomic) AVCaptureSession *captureSession;//负责输入和输出设置之间的数据传递
@property (strong,nonatomic) AVCaptureDeviceInput *captureDeviceInput;//负责从AVCaptureDevice获得输入数据
@property (strong,nonatomic) AVCaptureStillImageOutput *captureStillImageOutput;//照片输出流
@property (strong,nonatomic) AVCaptureVideoPreviewLayer *captureVideoPreviewLayer;//相机拍摄预览图层

@property (strong,nonatomic) AVCaptureMovieFileOutput *captureMovieFileOutput;//视频输出流

@property (assign,nonatomic) BOOL enableRotation;//是否允许旋转（注意在视频录制过程中禁止屏幕旋转）
@property (assign,nonatomic) CGRect *lastBounds;//旋转的前大小
@property (assign,nonatomic) UIBackgroundTaskIdentifier backgroundTaskIdentifier;//后台任务标识
@property(weak,nonatomic)id<CameraMangerDelegate>cameraDelegate;



- (void)addStillImageOutput;
- (void)captureStillImage;
- (void)addVideoPreviewLayer;
- (void)initiateCaptureSessionForCamera:(CameraType)cameraType;
- (void)stop;
-(void)setupCaptureImageManager:(CameraType)cameraType;
-(void)changCamera;
-(void)videoRecord;


-(void)setupCaptureVideoManager:(CameraType)cameraType;

@end
